#include <stdio.h>
#include <mxml.h>
int main(int argc, char const *argv[])
{
    //文件头
    mxml_node_t* root = mxmlNewXML("1.0");
    //根标签
    mxml_node_t* china = mxmlNewElement(root,"china");
    //子标签 北京
    mxml_node_t* city = mxmlNewElement(china, "city");
    mxmlElementSetAttr(city,"name","北京");
    //面积
    mxml_node_t* area = mxmlNewElement(city,"area");
    mxmlNewText(area,0,"16410平方公里");
    //人口
    mxml_node_t* population = mxmlNewElement(city, "population");
    mxmlNewText(population,0,"2171万人");
    //gdp
    mxml_node_t* gdp = mxmlNewElement(city, "GDP");
    mxmlNewText(gdp,0,"24541亿元");

    //子标签 东京
    city = mxmlNewElement(china, "city");
    mxmlElementSetAttr(city,"name","东京");
    //面积
    area = mxmlNewElement(city,"area");
    mxmlNewText(area,0,"2188平方公里");
    //人口
    population = mxmlNewElement(city, "population");
    mxmlNewText(population,0,"3670万人");
    //gdp
    gdp = mxmlNewElement(city, "GDP");
    mxmlNewText(gdp,0,"31700亿元");

    //数据保存到磁盘文件
    FILE* fp = fopen("china.xml","w");
    mxmlSaveFile(root, fp, MXML_NO_CALLBACK);
    fclose(fp);
    mxmlDelete(root);
    return 0;
}
